package org.study.seataat.stock;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 作用描述
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2024年01月25日
 */
@Slf4j
@EnableDiscoveryClient
@MapperScan("org.study.seataat.**.mapper")
@SpringBootApplication(scanBasePackages = {"org.study.seataat.stock"}, exclude = DataSourceAutoConfiguration.class)
public class SeataAtStockApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext run = SpringApplication.run(SeataAtStockApplication.class, args);
        ConfigurableEnvironment environment = run.getEnvironment();
        StringBuilder commandLog = new StringBuilder();
        commandLog.append("\n+=================================================================================");
        commandLog.append("\n+        项目[{}]启动成功");
        commandLog.append("\n+        当前环境：{}");
        commandLog.append("\n+        服务地址：{}:{}");
        commandLog.append("\n+        SEATA模式：AT");
        commandLog.append("\n+=================================================================================");
        log.info(commandLog.toString(),
                environment.getProperty("spring.application.name"),
                environment.getProperty("spring.profiles.active"),
                InetAddress.getLocalHost().getHostAddress(),
                environment.getProperty("server.port"));
    }
}
